const isLength = (str) => {
  return str.length > 8
}
const lessThree = (str) => {
  let num = 0
  if (/[\d]/.test(str)) num++
  if (/[a-z]/.test(str)) num++
  if (/[A-Z]/.test(str)) num++
  if (/[^a-zA-Z\d]/.test(str)) num++
  return num >= 3
}

const isRepeat = (str) => {
  const arr = []
  for (let i = 0; i < str.length; i++) {
    const sub = str.substring(i, i + 3)
    if (arr.indexOf(sub) > -1) return false
    else arr.push(sub)
  }
  return true
}

const isValid = (s) => {
  let r = 'NG'
  let len = isLength(s)
  let type = lessThree(s)
  let repeat = isRepeat(s)

  if (len && type && repeat) {
    r = 'OK'
  }

  return r
}

while ((l = readline())) {
  console.log(isValid(l))
}
